<!--自由课程调查页-->
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="format-detection" content="telephone=no" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
		<script src="../../script/mui.min.js"></script>
		<script src="../../script/jquery.min.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/swiper-3.4.2.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/exam.css">
		<link rel="stylesheet" type="text/css" href="../../css/people_diaocha.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/singlePeo_diaocha.css"/>
		<title>自由课程调查章节页</title>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			.diaocha_question:nth-child(1) {
				padding-top: 10px;
			}
			.question_main .question_answer {
				padding: 0.2em 0em 0em 2em;
				background: #fff;
				margin-bottom: 20px;
			}
			.question_title1 {
				font-size: 16px;
				color: #333333;
				padding: 0.1em 1em 0 1em;
				margin-bottom: 2px;
			}
			.question_title {
				font-size: 16px;
				color: #333333;
				padding: 0.2em 1em 0.2em 1em;
				margin-bottom: 2px;
			}
			.stu-test .mui-btn-primary {
				color: #fff;
				background-color: #FF9900;
				border: 1px solid #FF9900;
				padding-left: 2em;
				padding-right: 2em;
			}
			.weui_mask {
				position: fixed;
				z-index: 998;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
			}
			.weui_dialog {
				z-index: 999;
			}
			.stu-test .test_card_div {
				font-size: 14px;
				position: absolute;
				right: 20px;
				top: -4px;
			}
			.test-answer-list .mui-checkbox.wrong input[type=checkbox]:checked, .test-answer-list .mui-radio.wrong input[type=radio]:checked {
				border-color: inherit;
				background-color: transparent;
			}
			.test-answer-list input[type=checkbox]:before, .test-answer-list input[type=radio]:before {
				color: #3e2727;
				display: block;
				text-align: center;
				line-height: 40px;
				font-family: inherit;
				font-size: 24px;
			}
			.swiper-wrapper {
				min-height: 500px;
				height: 100%
			}
			.question_answer li {
				line-height: 30px;
			}
			.Bar_center {
				margin-top: 2px;
				margin-bottom: 12px;
			}
			.Bar_left {
				margin-top: 10px;
				margin-bottom: 12px;
			}
			.question_answer li p {
				margin-bottom: 4px
			}
			.nomalColor {
				background: #FFFFFF
			}
			.Bar_right img {
				height: 12px;
				width: 12px;
			}
			.questionItemImgDiv {
				height: 60%;
				width: 80%;
				max-height: 200px;
				max-width: 95%;
				margin-left: 13px;
			}
			.xuanzeImgDiv {
				width: 90%;
				height: 8em
			}
			.tiankong {
				font-family: inherit;
				border-bottom: 1px solid #000;
				margin: 0 8px;
				text-align: center;
				width: auto;
				/*word-break:break-all*/
			}
			.question_video_div {
				padding: 10px 10px;
				padding-left: 20px;
			}
			.question_video_div	video {
				width: 100%;
				height: 13em;
				background-color: black;
			}
			.question_video_div	img {
				width: 100%;
				height: 10em;
				background-color: black;
			}
			.question_answer .option_video_div {
				padding: 10px 10px;
				padding-right: 20px;
			}
			.test-answer-list .option_video_div {
				padding: 10px 10px;
				padding-left: 50px;
			}
			.option_video_div	img {
				width: 100%;
				height: 8rem;
				background-color: black;
			}
			.option_video_div	video {
				width: 100%;
				height: 12em;
			}
		</style>
	</head>
	<body >
		<div class="stu-test" id="scroll">
			<div class="base_style_color" id='BarAppearance' style="height: 22px;width: 100%; position:fixed; left: 0px;top:0px;z-index: 998" ></div>
			<div class="base_navigation_bar base_style_color base_navigation_item_bar" style="position: fixed;left: 0px;top: 20px;">
				<a class="base_left_item" href="#" onclick="backToast()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
				<span id="title"></span>
			</div>
			<div class="ReviewWeekly_div  " style="margin-top: 64px"></div>
			<div class="space10"></div>
			<div class="k-con-border qusetion-type" >
				<div class="k-con-part clearfix test-num-bar">
					<p class="k-text-center k-c323 k-f12">
						<span class="test-score-detail "> 调查日期：<span class="k-cred" id="score"></span> </span>
					</p>
				</div>
			</div>
			<div class="k-con test-m-bottom70 test-analysis" id="question_div">
				<div class="question_main">
					<div class="swiper-container">
						<div class="swiper-wrapper" >
							<!--	<div class="swiper-slide" id="item' + (i + 1) + '" itemtype="' + data[i].ques[0].types + '">
							<div class="k-con-part3 clearfix">
							<span id="itemType" class="k-f18">单选题</span>
							<p class="k-f16 k-c323 k-mt5 indent-5">
							1111
							</p>
							<div  class="test-answer-list left_10" itemid="' + data[i].ques[0].id + '"     onclick="GetAnswerData(' + i + ')" >
							<div  class="mui-input-row mui-radio mui-left ">
							<div class="option_video_div"  video-url="' + VideoUrlArr[0] + '" onclick="toPlayVideo(this)"><img src="../../image/img_voide.png"/></div>
							<input    Itemindex="' + i + '"  dataindex="' + data[i].ques[0].allitem[k].id + '"   name="radio' + data[i].ques[0].id + '"   type="radio"  itemid="' + data[i].ques[0].id + '">
							</div>
							</div>
							</div>
							</div>-->
						</div>
					</div>
				</div>
			</div>
			<div class="k-con1 k-text-center k-fixed-bottom test-bottom1" id="sub_div">
				<div class="k-con-part1" id='sub_bt' style="display: none;">
					<button type="button" class="mui-btn mui-btn-primary" onclick="CheckSubmit()" >
						提交
					</button>
					<div class="test_card_div">
						<a class="base_right_item "style="color: #18B4ED" href="#popover-card">答题卡 </a>
					</div>
				</div>
				<div class="k-con-part" id='score_bt' style="height:27px;display: none;">
					<div class="test_card_div" style="top: -10px">
						<a class="base_right_item "style="color: #18B4ED" href="#popover-card">答题卡 </a>
					</div>
				</div>
			</div>
			<div id="popover-card" class="mui-popover test-num-card" style="height: 180px;width: 97% ">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll" id="scroll-card"></div>
				</div>
			</div>
			<div id="backAlert" class="weui_dialog_confirm" style="display: none">
				<div class="weui_mask"></div>
				<div class="weui_dialog">
					<div class="weui_dialog_hd">
						<strong class="weui_dialog_title" id="checkNum"></strong>
					</div>
					<div class="weui_dialog_bd"></div>
					<div class="weui_dialog_ft">
						<a onclick="cleanCancel()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
						<a onclick="cleanConfirm()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
					</div>
				</div>
			</div>
			<div class="weui_dialog_alert" id="closeAlert" style="display: none">
				<div class="weui_mask"></div>
				<div class="weui_dialog">
					<div class="weui_dialog_hd">
						<strong class="weui_dialog_title" id="checkNum2"></strong>
					</div>
					<div class="weui_dialog_ft">
						<a onclick="Cancel()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script src="../../script/timecontrol.min.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/swiper-3.4.2.jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/echarts.min.js"></script>
	<script type="text/javascript" src="../../script/attachmentManager.js"></script>
	<script type="text/javascript" src="../../script/ResearchUi.js"></script>
	<script src="../../script/common.js"></script>
	<script>
		//题目名称数组
		var daan = new Object();
		var itemNameArr = new Array();
		var qidArr = new Array();
		var pid = "";
		// 计划id
		var cid = "";
		var clickNum = "";
		//课程id
		var chapterid = "";
		//章节id
		var timeNum = "";
		var questionLen = "";
		apiready = function() {
			preData();
			scrollUI();
			//开启加载框
			showProgress();
			// 滚动监听
			listenScroll();
			//获取数据
			judgeTestType();
			//获取答题数据
			ReceNotifi();
		}
		function ReceNotifi() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				//coding...
				backToast();
			});
		}

		function preData() {
			var pageParam = api.pageParam;
			var h = api.winHeight * 0.3;
			$('#popover-card').css('height', h);
			//如果是从自由课程列表跳转过来
			if (api.pageParam.hasOwnProperty('isfreecorse')) {
				var Research_title = $api.getStorage('Research_title');
				$('#title').text(isStringNull(Research_title));
			} else {
				$('#title').text(isStringNull(api.pageParam.cdetailtitle));
			}
		}

		//判断当前测验章节的状态
		function judgeTestType() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				pid : api.pageParam.pid,
				vid : api.pageParam.id,
			};
			cfnetppPOST(url_getChapterType, param, false, function(data, status) {
				if (status == 'success') {
					hideProgress();
					if (data.code == 200) {
						var list = data.data;
						if (list != null && list != '') {
							var timestamp = (Date.parse(new Date())) / 1000;
							var statime = parseInt(list.statime);
							var endtime = parseInt(list.endtime);
							if (list.is_survey == 0) {
								if (timestamp - endtime < 0 && timestamp - statime > 0) {
									loadExamData();
								} else if (timestamp - endtime > 0 && timestamp - statime > 0) {
									PopupHint2('该调查章节已过期');
									clickNum = 4;
								} else if (timestamp - statime < 0) {
									PopupHint2('当前调查章节未到开始时间');
								} else {
								}
							} else {
								loadScoreData();
								clickNum = 4;
							}
						} else {
							PopupHint2('当前章节数据为空');
						}
					} else if (data.code == 128) {
						PopupHint2('当前章节数据为空');
						clickNum = 3;
					} else {
						PopupHint2('数据异常');
						clickNum = 3;
					}
				} else {
					api.toast({
						msg : '网络异常',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		function PopupHint2(str) {
			api.hideProgress();
			$("#checkNum2").text(str);
			$('#closeAlert').show();
		}

		function Cancel() {
			$('#closeAlert').hide();
			closeWindow();
		}

		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
				vid : api.pageParam.id,
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : $api.getStorage('Research_sourceurl'),
				sourcetitle : $api.getStorage('Research_sourcetitle'),
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		//调查考试页
		function loadExamData() {
			sendBuriedNotifi('0', '提交调查', '051');
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				id : api.pageParam.rid,
			};
			cfnetppPOST(url_getSurvey, param, true, function(data, status) {
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						var list = data.json;
						if (list != null) {
							$('#sub_bt').show();
							$('#score').text(getLocalTime(isStringNull(list.btime)) + "~" + getLocalTime(isStringNull(list.etime)));
							if (list.examlist != '' && list.examlist != null) {
								setUpObject(list.examlist);
								SetExamUI(list.examlist);
							} else {
								PopupHint2('考试题目为空');
							}
						} else {
							PopupHint2('该调查题目为空');
						}
					} else if (data.code == 106) {
						PopupHint2('调查未找见');
					} else {
					}
				} else {
					api.toast({
						msg : '网络异常',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		//调查结果页
		function loadScoreData() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				vid : api.pageParam.id,
				pid : api.pageParam.pid,
				id : api.pageParam.rid,
			};
			cfnetppPOST(url_SurveyInfo, param, true, function(data, status) {
				api.refreshHeaderLoadDone();
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						sendBuriedNotifi('0', '调查结果', '052');
						$('#score_bt').show();
						var list = data.json;
						if (list != null) {
							$('#score').text(getLocalTime(isStringNull(list.btime)) + "~" + getLocalTime(isStringNull(list.etime)));
							if (list.examlist != '' && list.examlist != null) {
								SetScoreUI(list.examlist);
							} else {
								PopupHint2('考试题目为空');
							}
						} else {
							api.toast({
								msg : '请在调查活动结束后查看答案，目前暂时不支持查看答案',
								duration : 2000,
								location : 'bottom'
							});
						}
					} else if (data.code == 106) {
						api.toast({
							msg : '调查未找见',
							duration : 2000,
							location : 'bottom'
						});
					} else {
						api.toast({
							msg : '没有更多数据了',
							duration : 2000,
							location : 'bottom'
						});
					}
				} else {
					api.toast({
						msg : '没有更多数据了',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		// 滚动监听
		function listenScroll() {
			var winHeight = $(window).height();
			//获取当前页面高度
			$(window).resize(function() {
				var thisHeight = $(this).height();
				if (winHeight - thisHeight > 50) {
					//当软键盘弹出，在这里面操作
					$("#sub_div").css('display', 'none');
				} else {
					$("#sub_div").css('display', 'block');
					//当软键盘收起，在此处操作
				}
			});
		}

		function SetExamUI(list) {
			var data = list;
			if (data != null) {
				questionLen = data.length;
				var questionStr = "";
				var optionStr = "";
				var scoreStr = "";
				for (var i = 0; i < questionLen; i++) {
					if (data[i].ques[0] != null && data[i].ques[0] != '' && data[i].ques != '[]') {
						scoreStr = (i + 1) + '/' + questionLen + "." + questionsImgIsNull(data[i].ques[0].names);
						$(".swiper-wrapper").append('<div class="swiper-slide" id="item' + (i + 1) + '" itemtype="' + data[i].ques[0].types + '"></div>')
						$("#item" + (i + 1)).append('<div class="k-con-part3 clearfix">' + '<span id="itemType" class="k-f18">' + data[i].names + '</span>' + '<p class="k-f16 k-c323 k-mt5 indent-5">' + scoreStr + '</p>' + '<div  class="test-answer-list left_10" itemid="' + data[i].ques[0].id + '"     onclick="GetAnswerData(' + i + ')" >' + '</div>' + '</div>')
						if (data[i].names == '单选题' || data[i].names == '判断题' || data[i].ques[0].types == 1 || data[i].ques[0].types == 3) {
							//	是单选或者判断
							for (var k = 0; k < data[i].ques[0].allitem.length; k++) {
								optionStr = optionImgIsNull(data[i].ques[0].allitem[k].dname);
								$("#item" + (i + 1) + " .test-answer-list").append('<div  class="mui-input-row mui-radio mui-left ">' + optionStr + '<input Itemindex="' + i + '"  dataindex="' + data[i].ques[0].allitem[k].id + '"   name="radio' + data[i].ques[0].id + '"   type="radio"  itemid="' + data[i].ques[0].id + '">' + '</div> ')
							}
						} else if (data[i].names == '多选题' || data[i].ques[0].types == 2) {
							//	是多选
							for (var k = 0; k < data[i].ques[0].allitem.length; k++) {
								optionStr = optionImgIsNull(data[i].ques[0].allitem[k].dname);
								$("#item" + (i + 1) + " .test-answer-list").append('<div  class="mui-input-row mui-checkbox mui-left">' + optionStr + '<input Itemindex="' + i + '"  dataindex="' + data[i].ques[0].allitem[k].id + '"    name="checkbox1" value="Item 1" type="checkbox" itemid="' + data[i].ques[0].id + '">' + '</div>')
							}
						} else if (data[i].names == '论述题' || data[i].ques[0].types == 4) {
							// 论述
							$("#item" + (i + 1) + " .test-answer-list").append('<div  class="test-answer-list">' + '<textarea Itemindex="' + i + '"  class="k-texttarea k-f14" id="content" itemid="' + data[i].ques[0].id + '"></textarea>' + '</div>')
						}
					} else {
						$(".swiper-wrapper").append('<div class="swiper-slide" id="item' + (i + 1) + '" itemtype="' + data[i].ques[0].types + '"></div>')
						$("#item" + (i + 1)).append('<div class="k-con-part clearfix tont" >' + '<p class="k-f16 k-c323 k-mt15">' + (i + 1) + "、" + '本题为空' + '</p>' + '<div  class="test-answer-list"      >' + '</div>' + '</div>')
					}
				}
				var mySwiper = new Swiper('.swiper-container', {
					autoHeight : true,
					//用户操作swiper之后，是否禁止autoplay
					autoplayDisableOnInteraction : true,
					direction : 'horizontal',
					loop : false,
				})
				//	生成答题卡题号
				popoverCardNum(questionLen);
				//  试题总数
				allQuestionNum(questionLen);
				// 点击答题卡切换
				$("#popover-card span").on("click", function() {
					//				gallery.slider().gotoItem($(this).index())
					var index = $(this).index();
					mySwiper.slideTo(index, 1000, false);
					mui('#popover-card').popover('hide')
				});
			}
		}

		function SetScoreUI(list) {
			var data = list;
			questionLen = data.length;
			//	生成答题卡题号
			TestScorePopoverCardNum(questionLen);
			var PercentageStr = '';
			var questionStr = "";
			var optionStr2 = "";
			var scoreStr = "";
			for (var i = 0; i < questionLen; i++) {
				questionStr = questionsImgIsNull(data[i].ques[0].names);
				scoreStr = (i + 1) + '/' + questionLen + ".";
				$(".swiper-wrapper").append('<div class="swiper-slide">' + '<div class="diaocha_question nomalColor"  id="item' + (i + 1) + '">' + '</div>' + '</div>');
				$("#item" + (i + 1)).append('<p class="question_title1">' + '<span><em style="color: #F0AD4E">' + (i + 1) + '</em>/' + questionLen + '</span>' + '<span class="question_type">' + '(' + data[i].names + ')' + '</span>' + '</p>' + '<p class="question_title">' + '<span>Q' + (i + 1) + '</span>' + questionStr + '</span>' + '</p>' + '<ul class="question_answer">' + '</ul>');
				if (data[i].daan != '' && data[i].daan.length > 0 && data[i].daan != '[]') {//答案正确
					$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-true');
				} else {
					$("#scroll-card").find("span").eq(i).removeClass('qusetion-num-selected').addClass('qusetion-num-false');
				}
				if (data[i].names == '单选题' || data[i].names == '判断题' || data[i].ques[0].types == 1 || data[i].ques[0].types == 3) {
					//	是单选或者判断
					for (var k = 0; k < data[i].ques[0].allitem.length; k++) {
						optionStr2 = optionImgIsNull(data[i].ques[0].allitem[k].dname);
						var optionStr = "option" + ((k + 1) % 7);
						var BgStr = "Bg" + ((k + 1) % 7);
						PercentageStr = PercentageIsNull(((data[i].ques[0].allitem[k].num) / (data[i].qunm)) * 100) + "%";
						$("#item" + (i + 1) + " .question_answer").append('<li>' + '<p style="font-size:14px">' + '<span>' + fromCharCode(k + 1) + '</span>' + optionStr2 + '</p>' + '<div class="progressBar ' + optionStr + '">' + '<div class="Bar_left ' + optionStr + '">' + '<div class="bar_in ' + BgStr + '"></div>' + '</div>' + '<div class="Bar_center">' + PercentageStr + '</div>' + '<div class="Bar_right"><img src="../../image/icon_Pmini.png" alt="">' + '<span>' + data[i].ques[0].allitem[k].num + '</span>' + '</div>' + '</div>' + '</li>');
					}
				} else if (data[i].names == '多选题' || data[i].ques[0].types == 2) {
					//	是多选
					for (var k = 0; k < data[i].ques[0].allitem.length; k++) {
						var optionStr = "option" + ((k + 1) % 7);
						var BgStr = "Bg" + ((k + 1) % 7);
						optionStr2 = optionImgIsNull(data[i].ques[0].allitem[k].dname);
						PercentageStr = PercentageIsNull(((data[i].ques[0].allitem[k].num) / (data[i].qunm)) * 100) + "%";
						//						alert(data[i].ques[0].allitem[k].num+'vs'+data[i].qunm);
						$("#item" + (i + 1) + " .question_answer").append('<li>' + '<p style="font-size:14px">' + '<span>' + fromCharCode(k + 1) + '</span>' + optionStr2 + '</p>' + '<div class="progressBar ' + optionStr + '">' + '<div class="Bar_left ' + optionStr + '">' + '<div class="bar_in ' + BgStr + '"></div>' + '</div>' + '<div class="Bar_center">' + PercentageStr + '</div>' + '<div class="Bar_right"><img src="../../image/icon_Pmini.png" alt="">' + '<span>' + data[i].ques[0].allitem[k].num + '</span>' + '</div>' + '</div>' + '</li>');
					}
				} else if (data[i].names == '论述题') {
				}
				GetWidth();
			}
			var mySwiper = new Swiper('.swiper-container', {
				autoHeight : true,
				//					autoplay: 2000,//可选选项，自动滑动
				//用户操作swiper之后，是否禁止autoplay
				autoplayDisableOnInteraction : true,
				//				pagination : '.swiper-pagination',
				direction : 'horizontal',
				loop : false,
			})
			//  试题总数
			allQuestionNum(questionLen);
			// 点击答题卡切换
			$("#popover-card span").on("click", function() {
				var index = $(this).index();
				mySwiper.slideTo(index, 1000, false);
				mui('#popover-card').popover('hide')
			});
		}

		//得到答案数据
		function GetAnswerData(slideNumber) {
			var duooptionid = '';
			//多选题选项id
			var danoptionid = '';
			//单选题选项id
			var duoQuestionid = '';
			//多选题题目id
			var danQuestionid = '';
			//单选题tiid
			var lunshuQuestionid = '';
			//论述题id
			var Itemindex = '';
			var duoQuestionidArr = new Array();
			var lunshuContent = '';
			var itemtype = $(".swiper-wrapper").children().eq(slideNumber).attr('itemtype');
			if (itemtype == 1 || itemtype == 2 || itemtype == 3) {//单选题,多选题,判断题
				$(".swiper-wrapper").children().eq(slideNumber).find('input').each(function(i) {
					if ($(this).attr('type') === 'radio') {
						if (this.checked == true) {
							danoptionid = $(this).attr('dataindex');
							danQuestionid = $(this).attr('itemid');
							Itemindex = $(this).attr('Itemindex');
							$("#scroll-card").find("span").eq(Itemindex).removeClass('qusetion-num-normal').addClass('qusetion-num-selected');
							daan[danQuestionid] = danoptionid;
						}
					} else if ($(this).attr('type') === 'checkbox') {
						//						Itemindex = $(this).attr('Itemindex');
						//						duoQuestionid = $(this).attr('itemid');
						if (this.checked == true) {
							duooptionid = $(this).attr('dataindex');
							duoQuestionid = $(this).attr('itemid');
							Itemindex = $(this).attr('Itemindex');
							$("#scroll-card").find("span").eq(Itemindex).removeClass('qusetion-num-normal').addClass('qusetion-num-selected');
							duoQuestionidArr.push(duooptionid);
						} else {
							duoQuestionidArr.splice(i, 1);
						}
						if (duoQuestionidArr.toString() == "") {
							$("#scroll-card").find("span").eq(Itemindex).removeClass('qusetion-num-selected').addClass('qusetion-num-normal');
						}
						daan[duoQuestionid] = duoQuestionidArr.toString();
					}
				});
			} else {
				$(".swiper-wrapper").children().eq(slideNumber).find('textarea').on('input', function() {
					lunshuQuestionid = $(this).attr('itemid');
					//				//论述题内容
					lunshuContent = $(this).val();
					Itemindex = $(this).attr('Itemindex');
					if (lunshuContent != null && lunshuContent != '') {
						$("#scroll-card").find("span").eq(Itemindex).removeClass('qusetion-num-normal').addClass('qusetion-num-selected');
					}
					daan[lunshuQuestionid] = lunshuContent;
				});
			}
		}

		//  试题总数
		function allQuestionNum(questionLen) {
			$("#questionLength").text("/" + questionLen)
		}

		//	生成答题卡题号
		function popoverCardNum(questionLen) {
			for (var i = 0; i < questionLen; i++) {
				$("#scroll-card").append('<span class="qusetion-num-normal">' + (i + 1) + '</span>')
			}
		}

		function setUpObject(data) {
			var questions = data;
			for (var i = 0; i < questions.length; i++) {
				var question = questions[i];
				var subQuestion = question.ques;
				//子问题数组
				if (question.names == '单选题' || question.names == '判断题') {//单选题
					for (var j = 0; j < subQuestion.length; j++) {
						var subQuestion = subQuestion[j];
						qidArr.push(subQuestion.id);
						//取出子题目
						daan[subQuestion.id] = new String();
					}
				} else if (question.names == '多选题') {//多选题
					for (var k = 0; k < subQuestion.length; k++) {
						var subQuestion = subQuestion[k];
						qidArr.push(subQuestion.id);
						//取出子题目
						daan[subQuestion.id] = new Array();
					}
				} else if (question.names == '论述题') {//论述题
					for (var g = 0; k < subQuestion.length; g++) {
						var subQuestion = subQuestion[g];
						qidArr.push(subQuestion.id);
						//取出子题目
						daan[subQuestion.id] = new Array();
					}
				}
			}
		}

		//清楚数组中为空的数据
		function DeleteAnswerNullData() {
			for (var k = 0; k < qidArr.length; k++) {
				if ( typeof daan[qidArr[k]] == 'string') {
					if (daan[qidArr[k]] == null || daan[qidArr[k]] == "" || daan[qidArr[k]] == undefined) {
						delete daan[qidArr[k]];
					}
				} else if ( typeof daan[qidArr[k]] == 'object') {
					if ( typeof daan[qidArr[k]].length == 'number') {
						if (daan[qidArr[k]].length == 0) {
							delete daan[qidArr[k]];
						}
					}
				}
			}
		}

		//检查题目是否提交
		function CheckSubmit() {
			DeleteAnswerNullData();
			var daanLen = ObjectCount(daan);
			var strLen = questionLen - daanLen;
			if (strLen > 0) {//剩余题目数量大于0
				$("#checkNum").text("您还有" + strLen + "道题未填写,是否确定填写?");
			} else {
				$("#checkNum").text("是否确定提交？");
			}
			$('#backAlert').show();
			clickNum = 1;
		}

		//退出考试提示
		function backToast() {
			if (clickNum == 4) {
				closeWindow();
			} else {
				$('#backAlert').show();
				$("#checkNum").text("是否确定退出本次调查?");
				clickNum = 2;
			}
		}

		//退出考试弹窗取消按钮
		function cleanCancel() {
			$('#backAlert').hide();
		}

		//退出考试弹窗确定按钮
		function cleanConfirm() {
			$('#backAlert').hide();
			//考试中途退出
			if (clickNum == 1) {
				//获取到最后一题的答案数据，并存进对象中
				SubmitData();
				//调查正常退出，调查章节过期，调查结果页退出
			} else if (clickNum == 2 || clickNum == 4) {
				closeWindow();
			}
		}

		//提交答题数据
		function SubmitData() {
			sendBuriedNotifi('1', '提交调查', '051');
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				pid : api.pageParam.pid,
				vid : api.pageParam.id,
				id : api.pageParam.rid,
				cid : api.pageParam.cid,
				answer : daan
			};
			if (JSON.stringify(daan) == "{}") {
				ShowToast('调查不可以提交空卷');
			} else {
				cfnetppPOST(url_subSurvey, param, false, function(data, status) {
					hideProgress();
					SendBusinessOperationsLogNotifi('自由课程提交调查页', '051', param, param, '', data, '自由课程提交调查结果接口', '051-01')
					if (status == 'success') {
						if (data.status == true) {
							if (data.code == 200) {
								ShowToast('提交成功');
								sendNotifi();
								openScore();
							} else if (data.code == 125) {
								ShowToast('请勿重复提交');
							} else {
								api.toast({
									msg : '提交失败',
									duration : 2000,
									location : 'bottom'
								});
							}
						} else {
							api.toast({
								msg : '提交失败',
								duration : 2000,
								location : 'bottom'
							});
						}
					} else {
						api.toast({
							msg : '请求失败',
							duration : 2000,
							location : 'bottom'
						});
					}
				});
			}
		}

		function sendNotifi() {
			api.sendEvent({
				name : 'freeCourseRecordNotifi',
				extra : {
					uid : $api.getStorage('cfnetppuid'),
					jid : $api.getStorage('cfnetppjxid'),
					cid : api.pageParam.cid,
					vid : api.pageParam.id, //章节id
					pid : api.pageParam.pid
				}
			});
		}

		//测验结果生成答题卡
		function TestScorePopoverCardNum(questionLen) {
			for (var i = 0; i < questionLen; i++) {
				$("#scroll-card").append('<span class="qusetion-num-selected" >' + (i + 1) + '</span>')
			}
		}

		//关闭到章节列表页
		function closeWindow() {
			sendBuriedNotifi('1', '调查结果', '052');
			//如果是从自由课程列表跳转过来
			if (api.pageParam.hasOwnProperty('isfreecorse')) {
				if (api.pageParam.hasOwnProperty('openType') && api.pageParam.openType == "train_stu") {//实习学习跳转而来
					api.closeToWin({
						name : 'Student_trainFreeCourseTab'
					});
				} else {//教学学习跳转而来
					api.closeToWin({
						name : 'Student_FreeCourseTab'
					});
				}
			} else {
				api.closeWin({
				});
			}
		}

		function openScore() {
			var cdetailtitle = "";
			if (api.pageParam.hasOwnProperty('isfreecorse')) {
				cdetailtitle = $api.getStorage('Research_title');
			} else {
				cdetailtitle = api.pageParam.cdetailtitle;
			}
			var y = 0;
			var h = api.winHeight - y;
			api.openWin({useWKWebView:true,
				name : 'New_Student_Study_ResearchExam',
				url : 'New_Student_Study_ResearchExam.html',
				rect : {
					x : 0,
					y : y,
					w : 'auto',
					h : h,
				},
				pageParam : {
					pid : api.pageParam.pid,
					rid : api.pageParam.rid, //测验id
					cid : api.pageParam.cid, //课程id
					id : api.pageParam.id, //章节id
					cdetailtitle : cdetailtitle,
					openType : api.pageParam.openType
				},
				reload : true
			});
		}
	</script>
</html>